//导入数据库操作模块

const db = require('../db/index')
exports.getGainCates=(req,res)=>{
    const sql = 'insert into ev_articles set ?'
    const act = {
        author_id:req.body.author_id,
        title:req.body.title,
        content:req.body.content
    }
    db.query(sql,act, (err, results) => {
        if (err){
            return res.cc(err)
        } 
        res.send({
            status: 0,
            message: '发布文章成功！',
            data: results,
        })
    })
}
//获取
exports.getAd=(req,res)=>{
    const sql = `select * from ev_articles`
    db.query(sql,{author_id:req.body.author_id,title:req.body.title,content:req.body.content}, (err, results) => {
        if (err){
            return res.cc(err)
        } 
        res.send({
            status: 0,
            message: '获取文章成功！',
            data: results,
        })
    })
}
//获取文章
exports.getReserve=(req,res)=>{
    const sql='select * from ev_articles where Id=?'
    db.query(sql,req.body.Id,(err,results)=>{
        if (err){
            return res.cc(err)
        } 
        res.send({
            status: 0,
            message: '嘿嘿嘿',
            dataA: results,
        })
    })
}